from django.contrib.auth.models import AbstractUser
from django.db import models


class Base(models.Model):
    # 是否注销
    is_delete = models.BooleanField(default=False)
    # 创建时间
    create_time = models.DateTimeField(auto_now_add=True)

    class Meta:
        abstract = True


class UserInfo(AbstractUser, Base):
    # 手机号
    phone = models.CharField(max_length=64, unique=True)
    # 性别
    sex = models.IntegerField(choices=[(0, '男'), (1, '女'), (3, '未知')], default=0)
    # 头像
    avatar = models.ImageField(upload_to='avatar/', default='avatar/default.png')
    # 真实姓名
    real_name = models.CharField(max_length=32)
    # 身份证
    id_card = models.CharField(max_length=64, unique=True)
    # 个性签名
    signature = models.CharField(max_length=32)
    # 支付密码
    payment_password = models.CharField(max_length=16)





class Address(Base):
    consignee_name = models.CharField(max_length=16, verbose_name='收货人姓名')
    phone = models.CharField(max_length=11, verbose_name='收件人手机号')
    addr = models.CharField(max_length=128, verbose_name='收件人地址')
    detail_addr = models.CharField(max_length=128, verbose_name='详细地址')
    is_default = models.BooleanField(default=False, verbose_name='是否默认地址')
    user = models.ForeignKey(to='UserInfo', on_delete=models.DO_NOTHING, verbose_name='用户id')

    class Meta:
        verbose_name = '地址'
        verbose_name_plural = verbose_name


